export default class HotGame {
  constructor(data = {}) {
    // 初始化所有属性
    this.add_username = data.add_username || "";
    this.blackLevel = data.blackLevel || "";
    this.blackid = data.blackid || 0;
    this.blackname = data.blackname || "";
    this.f_add_userid = data.f_add_userid || "";
    this.f_degreeofopenness = data.f_degreeofopenness || 0;
    this.f_gametype = data.f_gametype || 0;
    this.f_result = data.f_result || "";
    this.f_round = data.f_round || "";
    this.f_state = data.f_state || 0;
    this.gameid = data.gameid || 0;
    this.hits = data.hits || 0;
    this.hot = data.hot || 0;
    this.isInterest = data.isInterest || 0;
    this.isPushST = data.isPushST || 0;
    this.isPushYK = data.isPushYK || 0;
    this.matchname = data.matchname || "";
    this.matchsort = data.matchsort || 0;
    this.start_time = data.start_time || "";
    this.top = data.top || 0;
    this.whiteLevel = data.whiteLevel || "";
    this.whiteid = data.whiteid || 0;
    this.whitename = data.whitename || "";
    this.win = data.win || 0;
  }

   // 静态方法从JSON创建实例
   static fromJson(json) {
    try {
      const data = JSON.parse(json);
      return new HotGame(data);
    } catch (e) {
      console.error("JSON解析错误:", e);
      return new HotGame();
    }
  }

  // 转换为JSON的方法
  toJson() {
    return JSON.stringify(this);
  }
}
